package GuiClasses;

/**
 * TCSS 360 - Project
 */

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Observable;
import java.util.Observer;

import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *  The main frame that the user will see while using the application.
 *  The midPanel will display user specific information.
 *  Implements the Observer interface.
 *  
 *  @author Abraham Santini
 */

public class BeWeaveFrame extends JFrame implements Observer{
	/**
	 * A JPanel that displays user specific information.
	 */
	private JPanel midPanel;
/**
 * Public constructor for the BeWeaveFrame.
 * Creates a BeWeaveFrame with midPanel set to a loginPanel.
 */
	public BeWeaveFrame() {

		setSize(new Dimension( 700, 700));
		this.setBackground(new Color(139, 101, 219));
		setLayout(new BorderLayout());
		JPanel top_panel = createTopPanel();
		add(top_panel, BorderLayout.NORTH);
		midPanel = new LoginPanel(this).getPanel();
		add(midPanel, BorderLayout.CENTER);
		
		add(createBottomPanel(), BorderLayout.SOUTH);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	} // end constructor

	private JPanel createTopPanel() {
		JPanel temp = new JPanel();
		temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS));
		temp.add(Box.createHorizontalGlue());
		temp.add(new LogoPanel());
		temp.add(new BeWeaveLogoPanel());
		return temp;
	}// end createTopPanel


	
	private JPanel createBottomPanel() {
		JPanel temp = new JPanel();
		temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS));
		temp.add(Box.createHorizontalGlue());
		temp.add(new SpiritBeastPanel());
		return temp;
		
	}
	
	/**
	 * Public update method that switches out panels.
	 * @param arg1 This must be a JPanel.
	 */
	@Override
	public void update(Observable arg0, Object arg1) {
		remove(midPanel);
		midPanel = (JPanel) arg1;
		add(midPanel);
		midPanel.revalidate();
		
	}
}// end BeWeaveFrame class


